package com.cyc.basic.leecode.other;


/**
 * @Description: 将字符串中的大写字母转化为小写字母
 * @version 1.0
 * @author cyc
 * @date 2021/9/24 15:19
 */
public class WordExchange {
    public static void main(String[] args) {
        Solution1 solution = new Solution1();
        String s = solution.toLowerCase("Hello");
        System.out.println(s);
    }
}

class Solution1 {
    public String toLowerCase(String s) {
        if (s == null || s.length() == 0) {
            return null;
        }
        StringBuilder sb =new StringBuilder();
        char[] chars = s.toCharArray();
        for (char c : chars) {
            if (c >= 'A' && c <= 'Z') {
                sb.append((char) (c + 32));
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}
